import shelve
from person import Person

fieldnames = ('name', 'age', 'job', 'pay')
db = shelve.open('class-shelve')

while True:
    key = input('\nKey? => ')
    if not key:
        break
    if key in db:
        record = db[key]
    else:
        record = Person(name='?', age='?')
    for field in fieldnames:
        curval = getattr(record, field)
        newval = input('\t[%s]=%s\n\tnew?=' % (field, curval))
        if newval:
            setattr(record, field, newval)
    db[key] = record
db.close()
